//
//  LoginMenuViewController.swift
//  LaiLang
//
//  Created by David on 2017/2/4.
//  Copyright © 2017年 David. All rights reserved.
//

import UIKit

class LoginMenuViewController: UIViewController {

    var backBtn: UIButton!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        title = "登陆"
        navigationController?.setNavigationBarHidden(true, animated: false)
        // Do any additional setup after loading the view.
        let image = UIImage(contentsOfFile: Bundle.main.path(forResource: "loginimg", ofType: "png")!)!
        let ivHeight = image.size.height * view.bounds.width / image.size.width
        let imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: view.bounds.width, height: ivHeight))
        imageView.image = image
        view.addSubview(imageView)
        
        view.backgroundColor = UIColor(hex: 0xf7f9fa)
        
        let regBtn = UIButton(frame: CGRect(x: 64, y: ivHeight + 128, width: view.bounds.width - 128, height: 44))
        regBtn.setTitleColor(UIColor.white, for: .normal)
        regBtn.backgroundColor = UIColor(r: 250, g: 146, b: 55)
        regBtn.layer.cornerRadius = 4
        regBtn.setTitle("手机注册", for: .normal)
        regBtn.titleLabel?.font = UIFont.systemFont(ofSize: 14)
        view.addSubview(regBtn)
        regBtn.addTarget(self, action: #selector(LoginMenuViewController.gotoReg), for: .touchUpInside)
        
        let weiboLoginBtn = UIButton(frame: CGRect(x: 64, y: ivHeight + 128 + 44 + 8, width: view.bounds.width - 128, height: 44))
        weiboLoginBtn.backgroundColor = UIColor.white
        weiboLoginBtn.layer.cornerRadius = 4
        
        var attrStr = NSMutableAttributedString(string: "\u{e64b} 微博登陆")
        attrStr.addAttribute(NSFontAttributeName, value: UIFont(name: "iconfont", size: 16)!, range: NSMakeRange(0, 1))
        attrStr.addAttribute(NSForegroundColorAttributeName, value: UIColor.red, range: NSMakeRange(0, 1))
        attrStr.addAttribute(NSForegroundColorAttributeName, value: UIColor(r: 120, g: 120, b: 120), range: NSMakeRange(2, 4))
        attrStr.addAttribute(NSFontAttributeName, value: UIFont.systemFont(ofSize: 14), range: NSMakeRange(2, 4))
        weiboLoginBtn.setAttributedTitle(attrStr, for: .normal)
        view.addSubview(weiboLoginBtn)
        weiboLoginBtn.addTarget(self, action: #selector(LoginMenuViewController.gotoWBLogin), for: .touchUpInside)
        
        let wxLoginBtn = UIButton(frame: CGRect(x: 64, y: ivHeight + 128 + 44 + 8 + 44 + 8, width: view.bounds.width - 128, height: 44))
        wxLoginBtn.backgroundColor = UIColor.white
        wxLoginBtn.layer.cornerRadius = 4
        attrStr = NSMutableAttributedString(string: "\u{e691} 微信登陆")
        attrStr.addAttribute(NSFontAttributeName, value: UIFont(name: "iconfont", size: 16)!, range: NSMakeRange(0, 1))
        
        attrStr.addAttribute(NSForegroundColorAttributeName, value: UIColor(r: 24, g: 167, b: 15), range: NSMakeRange(0, 1))
        attrStr.addAttribute(NSForegroundColorAttributeName, value: UIColor(r: 120, g: 120, b: 120), range: NSMakeRange(2, 4))
        attrStr.addAttribute(NSFontAttributeName, value: UIFont.systemFont(ofSize: 14), range: NSMakeRange(2, 4))
        wxLoginBtn.setAttributedTitle(attrStr, for: .normal)
        view.addSubview(wxLoginBtn)
        wxLoginBtn.addTarget(self, action: #selector(LoginMenuViewController.gotoWXLogin), for: .touchUpInside)
        
        
        
    }
    
    func gotoReg(){
//        navigationController?.pushViewController(RegViewController(), animated: true)
    }
    
    func gotoWBLogin(){
        print("gotoWBLogin")
        
    }
    
    func gotoWXLogin(){
        print("gotoWXLogin")
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
